#include "DyeField3.h"

using namespace FlowSim;
using namespace Ogre;

DyeField3::DyeField3(int size):_size(size)
{
  //allocate data
  // _rData = new uint8[size*size];
//   _gData = new uint8[size*size];
//   _bData = new uint8[size*size];
  _rData = new Real[size*size];
  _gData = new Real[size*size];
  _bData = new Real[size*size];
}

DyeField3::~DyeField3()
{
  delete _rData;
  delete _gData;
  delete _bData;
}

Real* DyeField3::getRData()
{
  return _rData;
}

Real* DyeField3::getGData()
{
  return _gData;
}

Real* DyeField3::getBData()
{
  return _bData;
}

auto_ptr<DyeField3> DyeField3::blankField(int size)
{
  auto_ptr<DyeField3> df(new DyeField3(size));
  // uint8* rd = df->getRData();
//   uint8* gd = df->getGData();
//   uint8* bd = df->getBData();
  Real* rd = df->getRData();
  Real* gd = df->getGData();
  Real* bd = df->getBData();
  std::fill(&rd[0],&rd[size*size-1],0);
  std::fill(&gd[0],&gd[size*size-1],0);
  std::fill(&bd[0],&bd[size*size-1],0);
  return df;
}

auto_ptr<DyeField3> DyeField3::testField(int size)
{
  auto_ptr<DyeField3> df(new DyeField3(size));
  // uint8* rd = df->getRData();
//   uint8* gd = df->getGData();
//   uint8* bd = df->getBData();
   Real* rd = df->getRData();
   Real* gd = df->getGData();
   Real* bd = df->getBData();
  for(int i=0;i<size;i++)
    {
      for(int j=0;j<size;j++)
	{
	  rd[A_INDEX(i,j,size)] = 0;
	  gd[A_INDEX(i,j,size)] = 0;
	  bd[A_INDEX(i,j,size)] = 0;
	}
    }
  return df;
}

